package cloud.seri.iot.aliyun.security

import cloud.seri.iot.aliyun.config.Constants
import org.springframework.data.domain.AuditorAware
import org.springframework.stereotype.Component
import java.util.*

/**
 * Implementation of [AuditorAware] based on Spring Security.
 */
@Component
class SpringSecurityAuditorAware : AuditorAware<String>
{

    override fun getCurrentAuditor(): Optional<String>
    {
        return Optional.of(SecurityUtils.getCurrentUserLogin().orElse(Constants.SYSTEM_ACCOUNT))
    }
}
